package cn.opopopo.design_pattern_learn.结构型.bridge;

class TV implements Device {
    private boolean on = false;
    private int volume = 30;
    private int channel = 1;

    @Override
    public void turnOn() {
        on = true;
        System.out.println("TV: 打开");
    }

    @Override
    public void turnOff() {
        on = false;
        System.out.println("TV: 关闭");
    }

    @Override
    public void setVolume(int volume) {
        if (on && volume >= 0 && volume <= 100) {
            this.volume = volume;
            System.out.println("TV: 音量设置为 " + volume);
        }
    }

    @Override
    public int getVolume() {
        return volume;
    }

    @Override
    public void setChannel(int channel) {
        if (on) {
            this.channel = channel;
            System.out.println("TV: 切换到频道 " + channel);
        }
    }

    @Override
    public int getChannel() {
        return channel;
    }
}